package com.lulee007.funnyv.adapter;

import android.support.v4.view.PagerAdapter;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;

import java.util.List;

/**
 * User: lulee007@live.com
 * Date: 2015-11-11
 * Time: 15:04
 */
public class MainViewPagerAdapter extends PagerAdapter{


    private List<View> mViewList;

    public  MainViewPagerAdapter(List<View> views){
        if(views==null)
            throw  new IllegalArgumentException("views cannot be null");
        this.mViewList=views;
    }

    @Override
    public int getCount() {
        return mViewList.size();
    }

    @Override
    public boolean isViewFromObject(View view, Object object) {
        return view==object;
    }

    @Override
    public Object instantiateItem(ViewGroup container, int position) {
        container.addView(mViewList.get(position));
        return mViewList.get(position);
    }

    @Override
    public void destroyItem(ViewGroup container, int position, Object object) {
        container.removeView(mViewList.get(position));
    }

    @Override
    public CharSequence getPageTitle(int position) {
        return " Page "+position;
    }
}
